

$(function(){
    $('.table tbody tr').click(function(){
        var index = parent.layer.getFrameIndex(window.name);
        var nid = parent.getNid();
        var $name = $(this).find('.name').text();
        var $employee_id = $(this).attr('employee_id');
        var c_id = $(this).attr('c_id');
        var avg_consume_amount = $(this).attr('avg_consume_amount');

        parent.$('[data-nid="'+nid+'"]').parent().append('<span>' +
            '<input type="hidden" name="avg_consume_amount[]" id="avg_consume_amount" value="'+avg_consume_amount+'">' +
            '<input type="hidden" name="beautycartd_id[]" value="'+c_id+'">' +
            '<input type="hidden" name="employee_name[]" value="'+$name+'">' +
            '<input type="hidden" name="employee_id[]" value="'+$employee_id+'">' +
            '<em class="empName mr10">'+$name+'</em>提成' +
            '<input class="reward" onblur="" name="reward[]" type="text" style="width: 38%;margin: 0 10px;height: 30px;line-height: 30px;border-radius: 5px;">' +
            '<a class="rest" href="javascript:;"><img src="/backend/img/service/close.png" alt=""/></a></span>');
        parent.$('[data-nid="'+nid+'"]').hide();

        parent.$('.reward').on('change',function(){
            $(this).each(function(){
                var r = /^-?\d+$/ ;
                var s = /^[0-9]+\.[0-9]{0,2}$/;
                if($(this).val() !=''&&!r.test($(this).val())&&!s.test($(this).val())){
                    $(this).val("");
                }
            });
        });

        parent.layer.close(index);
    })
});

